<?php

namespace Home\Controller;
use Home\Logic\GoodsLogic;
use Think\Page;

class ApplyController extends BaseController {
    public function index(){ 
        $userid=session('user.user_id');
        $userinfo=M('users')->find($userid);

        $uni_dzcode=uni_dzcode();
        $this->assign('uni_dzcode', $uni_dzcode); 
        $this->assign('userinfo', $userinfo); 
        $this->display();
    }
   /**
    * 商品详情页
    */ 
    public function adddz(){
        $data=I('post.');
        $data['is_dz']=1;
        $data['dzapply_time']=time();
        unset($data['__hash__']);
       $r= M('users')->save($data);
        if ($r) {
            $this->success('申请成功，等待管理员审核');
        }else{
            $this->error('申请失败');
        }
       
    } 
    
    
    /**
     * 团购活动列表
     */
    public function group_list()
    {
    	$count =  M('GroupBuy')->where(time()." >= start_time and ".time()." <= end_time ")->count();// 查询满足要求的总记录数
    	$Page = new \Think\Page($count,20);// 实例化分页类 传入总记录数和每页显示的记录数  	
    	$show = $Page->show();// 分页显示输出
    	$this->assign('page',$show);// 赋值分页输出
        $list = M('GroupBuy')->where(time()." >= start_time and ".time()." <= end_time ")->limit($Page->firstRow.','.$Page->listRows)->select(); // 找出这个商品        
        $this->assign('list', $list);
        $this->display();
    }
}